#include "EditorCore/Selector.h"

using namespace cmn;

namespace editor_core {

	Selector::Selector() :
		m_selectedEntity( 0 )
	{}

	Selector::~Selector() {}

	void Selector::GetViewers( ICollection<IEntityViewer*>* viewers ) const {
		for( IteratorPtr<IEntityViewer*> iter( m_viewers ); !iter.IsEnd(); iter.Next() ) {
			viewers->Add( iter.Current() );
		}
	}

	void Selector::SelectEntity( IEntity* entity ) {
		if( m_selectedEntity ) m_selectedEntity->SetSelected( false );
		m_selectedEntity = entity;
		if( m_selectedEntity ) m_selectedEntity->SetSelected( true );

		for( IteratorPtr<IEntityViewer*> iter( m_viewers ); !iter.IsEnd(); iter.Next() ) {
			iter.Current()->SetEntity( m_selectedEntity );
		}
	}
}
